package linter.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import linter.POJO.DO.UserFile;
import linter.mapper.UserFileMapper;
import linter.service.UserFileService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Date;

import static linter.custom.CustomResultType.SAVE_NOT_ERROR;
import static linter.custom.CustomResultType.SAVE_SUCCESS;

/**
* @author 北煜
* @description 针对表【user_file(用户上传数据文件信息)】的数据库操作Service实现
* @createDate 2024-04-09 20:05:55
*/
@Service
public class UserFileServiceImpl extends ServiceImpl<UserFileMapper, UserFile>
    implements UserFileService{

    @Resource
    UserFileMapper userFileMapper;

    @Override
    public String saveById(Long uuid, String key, String type, String fileType) {
        Date data = new Date();
        UserFile userFile = new UserFile();
        userFile.setUuid(uuid);
        userFile.setFilename(key);
        userFile.setModeltype(type);
        userFile.setFiletype(fileType);
        userFile.setCreatetime(data);
        userFile.setUpdatatime(data);
        int flag = userFileMapper.insert(userFile);
        return flag != 1 ? SAVE_NOT_ERROR : SAVE_SUCCESS;
    }
}




